# -*- coding: utf-8 -*-
# @Time : 2023/11/21 20:19
# @Author : 支晓光
# @Email : 1473858993@qq.com
# @File : to_first_page.py
# @Project : youguuUI
from time import sleep
from appium.webdriver.common.appiumby import AppiumBy
from common.base_page import BasePage


class ToFirstPage(BasePage):
    # 首页
    permission_allow_button = AppiumBy.ID,'com.android.packageinstaller:id/permission_allow_button'
    TextView = AppiumBy.CLASS_NAME, 'android.widget.TextView'
    # 点击首页
    btn_desktop_discovery = AppiumBy.ID, 'com.jhss.youguu:id/btn_desktop_discovery'
    # 点击头像
    head_pic = AppiumBy.ID, 'com.jhss.youguu:id/head_pic'
    # 点击登录
    btn_login = AppiumBy.ID, 'com.jhss.youguu:id/btn_login'
    # 点击账号密码登录
    tv_change_login_type = AppiumBy.ID, 'com.jhss.youguu:id/tv_change_login_type'
    # 输入账号
    et_username = AppiumBy.ID, 'com.jhss.youguu:id/et_username'
    # 输入密码
    et_password = AppiumBy.ID, 'com.jhss.youguu:id/et_password'
    # 点击登录

    bt_login = AppiumBy.ID, 'com.jhss.youguu:id/bt_login'

    def first_business(self):
        sleep(3)
        # 左滑三次
        self.swip_left(3)
        # 即刻启程
        self.click_ele(self.TextView)
        # 允许
        self.click_ele(self.permission_allow_button)
        self.click_ele(self.permission_allow_button)

    def login_business(self, username, password):
        # 点击首页
        self.click_ele(self.btn_desktop_discovery)
        # 点击头像
        self.click_ele(self.head_pic)
        # 点击登录
        self.click_ele(self.btn_login)
        # 点击账号密码
        self.click_ele(self.tv_change_login_type)
        # 输入账号
        self.send_keys(self.et_username, username)
        # 输入密码
        self.send_keys(self.et_password, password)
        sleep(2)
        # 点击登录
        self.click_ele(self.bt_login)
        sleep(2)

